#include "stdafx.h"
#include "wf_selectlayer.h"

#include "pf_selection.h"



WF_SelectLayer::WF_SelectLayer(PF_Container& container,
        PF_GraphicView& graphicView)
        :PF_ActionInterface("Select Layers", container, graphicView) {

    en = NULL;
}


QAction* WF_SelectLayer::createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/) {
    QAction* action = new QAction(tr("(De-)Select Layer"), NULL);
	action->setIcon(QIcon(":/extui/selectlayer.png"));
    //action->zetStatusTip(tr("(De-)Selects layers"));
    return action;
}


void WF_SelectLayer::trigger() {
    if (en!=NULL) {
        PF_Selection s(*container, graphicView);
        s.selectLayer(en);
        if (PF_DIALOGFACTORY!=NULL) {
            PF_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
        }
    } else {
        PF_DEBUG->print("PF_ActionSelectLayer::trigger: Entity is NULL\n");
    }
}



void WF_SelectLayer::mouseReleaseEvent(PF_MouseEvent* e) {
    if (e->button()==Qt::RightButton) {
        init(getStatus()-1);
    } else {
        en = catchEntity(e);
        trigger();
    }
}



void WF_SelectLayer::updateMouseCursor() {
    graphicView->setMouseCursor(LX_Define::SelectCursor);
}

// EOF
